package ace.module.stock.core.autoconfig;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.FilterType;
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
import org.springframework.stereotype.Repository;
import org.springdoc.core.models.GroupedOpenApi;
import ace.cmp.jetcache.anno.config.EnableAceMethodCache;
import ace.cmp.spring.data.jdbc.querydsl.core.QuerydslJdbcRepositoryExtendFactoryBean;
import ace.module.stock.core.impl.StockCoreBootstrapScanner;
import ace.module.stock.core.impl.dao.repository.RepositoryScanner;
import ace.module.stock.core.impl.properties.StockCoreProperties;

/**
* boostrap auto config.
*
* @author Caspar
*/
@EnableAspectJAutoProxy(exposeProxy = true)
@EnableAceMethodCache(basePackageClasses = {StockCoreBootstrapScanner.class})
@EnableConfigurationProperties({StockCoreProperties.class})
@EnableJdbcRepositories(basePackageClasses = {RepositoryScanner.class}, repositoryFactoryBeanClass = QuerydslJdbcRepositoryExtendFactoryBean.class)
@ComponentScan(basePackageClasses = StockCoreBootstrapScanner.class,
    excludeFilters = {
          @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Repository.class)
    })
@Configuration
public class StockCoreAutoConfig {
    @Bean
    public GroupedOpenApi stockGroupedOpenApi() {
        return GroupedOpenApi.builder()
                .group("stock")
                .displayName("仓库服务")
                .packagesToScan(StockCoreBootstrapScanner.class.getPackageName())
                .build();
    }
}